import request from '@/utils/request'
// 登录页面的接口请求
export const loginAPI = ({ username, password }) => request({
  url: '/user/login',
  method: 'POST',
  data: {
    username,
    password
  }
})
// 用户登出接口
export const logoutAPI = () => request({
  url: '/user/logout',
  method: 'POST'
})
// 获取用户的信息资料
export const getUserInfoAPI = () => request({
  url: '/user'
})
// 轮播图的请求接口
export const bannerAPI = () => request({
  url: '/home/swiper'
})
// 城市列表的请求接口
export const cityListAPI = () => request({
  url: '/area/city',
  params: {
    level: 1
  }
})
// 租房小组
export const groupsInfoAPI = ({ area }) => request({
  url: '/home/groups',
  params: {
    area
  }
})
// 最新资讯
export const getNewsAPI = (id) => request({
  url: '/home/news',
  params: {
    area: id
  }
})

// 热门城市
export const hotCityListAPI = () => request({
  url: '/area/hot'
})
// 找房api
export const houseListItemAPI = (cityInfo) => request({
  url: '/houses',
  params: cityInfo
})
// 区域找房
export const houseListAreaAPI = (id) => request({
  url: '/houses/condition',
  params: {
    id
  }
})
/// area/info 根据城市名称查询城市信息
export const cityNameSearchAPI = (name) => request({
  url: '/area/info',
  params: {
    name
  }
})
// 查询地图房源数据
export const searchMapCityAPI = (id) => request({
  url: '/area/map',
  params: {
    id
  }
})
// 查询房屋具体信息
export const searchDetailAPI = (id) => request({
  url: `/houses/${id}`
})
// 查看已发布的房源列表
export const houseSourceAPI = () => request({
  url: '/user/houses'
})
// 发布房源
export const publishHouseAPI = (body) => request({
  url: '/user/houses',
  method: 'POST',
  data: body
})
// 发布房屋所需条件
export const publishConditionAPI = () => request({
  url: '/houses/params'
})
// 小区关键字查询
export const areaSearchKeywordAPI = ({ name, id }) => request({
  url: '/area/community',
  params: {
    name,
    id
  }
})
// 房屋图像上传
export const uploadImgsAPI = (form) => request({
  url: '/houses/image',
  method: 'POST',
  data: form,
  headers: {
    authorization: 'multipart/form-data'
  }
})
// 我的收藏列表
export const favoriteAPI = () => request({
  url: '/user/favorites'
})
// 查询是否收藏
export const confirmFavoriteAPI = (id) => request({
  url: `/user/favorites/${id}`
})
// 添加收藏
export const addFavoriteAPI = (id) => request({
  url: `/user/favorites/${id}`,
  method: 'POST'
})
// 删除收藏
export const deleteFavoriteAPI = (id) => request({
  url: `/user/favorites/${id}`,
  method: 'DELETE'
})
